//    Copyright (C) Kherty.  All rights reserved.
using OpenLS.Core.Serialization;
using OpenLS.Spreadsheet.Office2003;

namespace OpenLS.Spreadsheet
{
	partial class Row
	{
        internal void ReadXml2003(ReadContext cTable, int availableRowIndex)
        {
            using (ReadContext cRow = cTable.Read("Row"))
            {
                Index = cRow.GetOptionalInteger(cRow.Namespace + "Index", availableRowIndex + 1) - 1;
                _height = cRow.GetOptionalDouble(cRow.Namespace + "Height");
                if (_height != null)
                    _height = PointsToPixelConverter.ToPixel(_height.Value);
                _hidden = cRow.GetOptionalBoolean(cRow.Namespace + "Hidden", false);
                string styleId = cRow.GetOptionalString(cRow.Namespace + "StyleID");
                if (styleId != null)
                    SetFormattingRecord(cRow.GetData<StyleLookup>()[styleId]);
                //\\autofit
                int availableColumnIndex = 0;
                while (cRow.ReaderLocalName == "Cell")
                {
                    Cell cell = Cell.CreateCellWithRow(this);
                    int columnSpan = cell.ReadXmlSpreadsheet(cRow, availableColumnIndex);
                    AddCellToDictionary(cell.Column.Index, cell);
                    availableColumnIndex = cell.Column.Index + columnSpan;
                }
            }
        }
	}
}
